package priv.lhy.log.config;

import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.core.annotation.Order;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import priv.lhy.log.core.LogInterceptor;

/**
 * @author : lihy
 * @date : 2021/8/5 11:31
 *
 */
@ConditionalOnProperty(prefix = "aop.log", name = "webEnable", havingValue = "true")
@Order(-1)
public class InterceptorConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //日志拦截器，增加 traceId 跟踪定位
        registry.addInterceptor(new LogInterceptor()).addPathPatterns("/**");
    }
}
